package Server.Poker.SSZLIU;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

import org.json.JSONObject;

import Server.Model.Base.SHMUser;


class IJsonExport {
	public String toString() {
		return getJsonData();
	}

	private String getJsonData() {
		return "";
	}

	public static String sprintf_BYTE(int by[][], int count) {

		int tmpCardData[] = new int[count]; // 用户扑克
		for (int i = 0; i < by.length; i++) {
			for (int k = 0; k < by[i].length; k++) {
				tmpCardData[i * by.length + k] = by[i][k];
			}
		}
		String strCardData = sprintf_BYTE(tmpCardData, count);
		return strCardData;
	}

	public static String sprintf_BYTE(Integer by[][], int count) {

		int tmpCardData[] = new int[count]; // 用户扑克
		for (int i = 0; i < by.length; i++) {
			for (int k = 0; k < by[i].length; k++) {
				tmpCardData[i * by.length + k] = by[i][k];
			}
		}
		String strCardData = sprintf_BYTE(tmpCardData, count);
		return strCardData;
	}

	public static String sprintf_BYTE(Integer by[], int count) {
		return sprintf_INT32(by, count);
	}

	public static String sprintf_BYTE(int by[], int count) {
		return sprintf_INT32(by, count);
	}

	public static String sprintf_DWORD(int dw[], int count) {
		return sprintf_INT32(dw, count);
	}

	public static String sprintf_INT32(Integer dw[], int count) {
		if (count < 1) {
			return "";
		}
		StringBuffer out_str = new StringBuffer();
		out_str.append(dw[0]);
		for (int i = 1; i < count; i++) {
			out_str.append(",");
			out_str.append(dw[i]);
		}
		return out_str.toString();
	}

	public static String sprintf_INT32(int dw[], int count) {
		if (count < 1) {
			return "";
		}
		StringBuffer out_str = new StringBuffer();
		out_str.append(dw[0]);
		for (int i = 1; i < count; i++) {
			out_str.append(",");
			out_str.append(dw[i]);
		}
		return out_str.toString();
	}

	public static String sprintf_DOUBLE(double dw[], int count) {
		if (count < 1) {
			return "";
		}
		StringBuffer out_str = new StringBuffer();
		out_str.append(big2(dw[0]));
		for (int i = 1; i < count; i++) {
			out_str.append(",");
			out_str.append(big2(dw[i]));
		}
		return out_str.toString();
	}
	static protected String big2(double d) {
		BigDecimal d1 = new BigDecimal(Double.toString(d)); 
		BigDecimal d2 = new BigDecimal(Integer.toString(1));
		return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP).toString();
	}
}

/***
 * 玩家请求进入房间
 */
class SUBCMD_S_Connect extends IJsonExport {

	int m_lUid;

	String getJsonData() {
		String sszliumsg = String.format("connect|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_GameIap extends IJsonExport{
	int uid;
	int seat;
	double coin;
	String getJsonData(){
		String mjmsg = String.format("gameiap|%d|%d|%g", uid,seat,coin);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", mjmsg);
		return json.toString();
	}
}
class SUBCMD_S_Join extends IJsonExport {

	int m_lUid;

	String getJsonData() {

		String sszliumsg = String.format("join|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 离开房间通知
class SUBCMD_S_Leave extends IJsonExport {

	int m_lUid;// 玩家ID

	String getJsonData() {

		String sszliumsg = String.format("leave|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 离开房间通知
class SUBCMD_S_Offline extends IJsonExport {

	int m_lUid;// 玩家ID

	String getJsonData() {

		String sszliumsg = String.format("offline|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};
class SUBCMD_S_OnLine extends IJsonExport{
	int uid;
	int seat;
	String getJsonData(){
		String mjmsg = String.format("online|%d|%d", uid,seat);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", mjmsg);
		return json.toString();
	}
}
class SUBCMD_S_InFore extends IJsonExport{
	int byActionUser;
	String getJsonData(){
		String niuniumsg = String.format("inFore|%d", byActionUser);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", niuniumsg);
		return json.toString();
	}
}

class SUBCMD_S_InBack extends IJsonExport{
	int byActionUser;
	String getJsonData(){
		String niuniumsg = String.format("inBack|%d", byActionUser);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", niuniumsg);
		return json.toString();
	}
}
class SUBCMD_S_ExprMsg extends IJsonExport{
	int m_uid1;
	int m_uid2;
	int m_index;
	String getJsonData() {

		String mjmsg = String.format("expr|%d|%d|%d", m_uid1, m_uid2,m_index);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", mjmsg);

		return json.toString();
	}
};
class SUBCMD_S_CreateRoom extends IJsonExport {

	int cbResult;
	int cbRound;
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("createroom|%d|%d|%d|%d", cbResult, cbRound, m_wUserChairID, m_dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Param extends IJsonExport {

	int m_dwTableID;// 房间ID
	String szParam;
	String roomDesc;
	double dwcKouYingRate;
	int m_kouYingJuShu;
	String getJsonData() {

		String sszliumsg = String.format("param|%d|%s|%s|%g|%d", m_dwTableID, szParam,roomDesc,dwcKouYingRate,m_kouYingJuShu);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_TryDismissRoom extends IJsonExport {
	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String sszliumsg = String.format("try_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_AgreeDismissRoom extends IJsonExport {
	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String sszliumsg = String.format("agree_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_RefuseDismissRoom extends IJsonExport {
	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String sszliumsg = String.format("refuse_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_DismissRoom extends IJsonExport {
	int cbResult;
	int lUid;
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("dismissroom|%d|%d|%d|%d", cbResult, lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_JoinRoom extends IJsonExport {
	int lUid;
	int cbResult;
	int dwTableID;// 房间ID
	int cbRound;
	int byParam[] = new int[20];
	String szGameName;
	String szGameDesc;

	String getJsonData() {

		String strParam = Arrays.toString(byParam);
		strParam = strParam.substring(1, strParam.length() - 1);

		String sszliumsg = String.format("joinroom|%d|%d|%d|%d|%s|%s|%s", lUid, cbResult, dwTableID, cbRound, strParam,
				szGameName, szGameDesc);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_AvatarURL extends IJsonExport { 		
	int	lUid;  
	String szURL;

	String getJsonData() {

		String sszliumsg = String.format("avatar|%d|%s", lUid, szURL);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Sit extends IJsonExport{		
	int	 m_lUid;      	
	int	 m_wUserChairID;//座位ID 
	int	 m_dwTableID;//房间ID
	int	 m_lUserScore;
	String	szNickName;
	int	m_cbGender;
	int		m_iAvatar;
	String	szIP;
	double m_lUserCoin;

	String getJsonData() {

		String sszliumsg = String.format("sit|%d|%d|%d|%d|%s|%d|%d|%s|%s", m_lUid, m_wUserChairID, m_dwTableID,
				m_lUserScore, szNickName, m_cbGender, m_iAvatar, szIP,big2(m_lUserCoin));
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_DenySit extends IJsonExport {
	int cbReason; // 1,没有找到房间,2，房间已满

	String getJsonData() {

		String sszliumsg = String.format("denysit|%d", cbReason);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Look extends IJsonExport{ 
	int m_lUid;     	
	int m_wUserChairID;//房间ID    	
	int m_iTotalCoin;
	String szNickName;

	String getJsonData() {

		String sszliumsg = String.format("look|%d|%d|%d|%d|%s", m_lUid, m_wUserChairID, m_iTotalCoin, szNickName);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_StandUp extends IJsonExport {

	int m_lUid;// 玩家ID
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID
	int leaveRoom;
	String getJsonData() {

		String sszliumsg = String.format("standup|%d|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID,leaveRoom);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Kick extends IJsonExport {

	int m_lUid;// 玩家ID
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("kick|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};


class SUBCMD_S_Error extends IJsonExport {
	int byRound;// 玩家ID
	int bySeatID;// 玩家座位
	int errCode;// 玩家座位
	String errMsg;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("error|%d|%d|%d|%s", byRound, bySeatID,errCode, errMsg);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Ready extends IJsonExport {
	int m_lUid;// 玩家ID
	int m_wUserChairID;// 玩家座位
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("ready|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 聊天表情
class SUBCMD_S_BiaoQing extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位
	int m_iBiaoQingIndex;

	String getJsonData() {

		String sszliumsg = String.format("biaoqing|%d|%d|%d", m_lUid, m_wUserChairID, m_iBiaoQingIndex);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_YuYin extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	int m_iYuYinIndex;

	String getJsonData() {

		String sszliumsg = String.format("yuyin|%d|%d|%d", m_lUid, m_wUserChairID, m_iYuYinIndex);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 送礼
class SUBCMD_S_SongLi extends IJsonExport {
	int m_srcUid;// 哪个玩家ID获得
	int m_dstUid;// 玩家座位 号
	int m_iLiWu;
	int m_srcCoin;// 送礼的人余下多少钱
	int m_dstCoin;// 收礼的人余下多少钱

	String getJsonData() {

		String sszliumsg = String.format("use|%d|%d|%d|%d|%d", m_srcUid, m_dstUid, m_iLiWu, m_srcCoin, m_dstCoin);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Avatar extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	String szAvatarURL;

	String getJsonData() {

		String sszliumsg = String.format("avatar|%d|%s", m_lUid, szAvatarURL);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Chat extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	String szContent;

	String getJsonData() {

		String sszliumsg = String.format("chat|%d|%d|%s", m_lUid, m_wUserChairID, szContent);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Voice extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	int seconds;
	String szVoiceURL;

	String getJsonData() {

		String sszliumsg = String.format("voice|%d|%d|%d|%s", m_lUid, m_wUserChairID, seconds, szVoiceURL);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SSeatInfo {
	int m_lUid;// UID
	int m_iTotalScore;// COIN
	String m_NickName;// NICKNAME
	int m_iBetCoin;//
	int m_cbGender;//
	int m_iAvatar;//
	int m_cbUserStatus;// 用户状态
	int m_iVipLevel;// VIP LEVEL
	int m_iTitle;// 称号
	int m_isLookon;// 是否观众
	String szIP;
	double m_iTotalCoin;

	public String toString() {

		String sszliumsg = String.format("%d#%d#%s#%d#%d#%d#%d#%d#%d#%d#%s#%s", m_lUid, m_iTotalScore, m_NickName, m_iBetCoin,
				m_cbGender, m_iAvatar, m_cbUserStatus, m_iVipLevel, m_iTitle, m_isLookon, szIP,big2(m_iTotalCoin));
		return sszliumsg;
	}
	public String big2(double d) {
		BigDecimal d1 = new BigDecimal(Double.toString(d)); 
		BigDecimal d2 = new BigDecimal(Integer.toString(1));
		return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP).toString();
	}
};
//TODO
class SUBCMD_S_Table extends IJsonExport{ //同步房间玩家信息
	int	 m_dwTableID;//房间ID			
	int	m_bTableStarted;//只要开始玩
	int	m_byRound;//
	int	m_byMaxRound;//		
	int	m_bGameStarted;//游戏开始	
	int	m_cntUser;//玩家数量
	int	m_cntLookon;//观众数量
	public SUBCMD_S_Table(){
		for (int i = 0; i < 6; i++) {
			 m_seatInfo[i] = new SSeatInfo();
		}
	}
	SSeatInfo	m_seatInfo[] = new SSeatInfo[6];
	public String getJsonData(){
		String sszliumsg = String.format("table|%d|%d|%d|%d|%d|%d|%d|%s|%s|%s|%s|%s|%s", m_dwTableID, m_bTableStarted, m_byRound, m_byMaxRound,m_bGameStarted, m_cntUser, m_cntLookon,
			m_seatInfo[0].toString(), m_seatInfo[1].toString(), m_seatInfo[2].toString(), 
			m_seatInfo[3].toString(),m_seatInfo[4].toString(),m_seatInfo[5].toString());
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);	
		
		return json.toString();		
	}
};

//TODO
//用户出牌
class SUBCMD_S_TableBegin extends IJsonExport {
	String strParam;
	int byRound;//
	int byMaxRound;
	int	bIsReady[] = new int[6];//
	int	bIsKaiPaiReady[] = new int[6];//	
	int lScore[] = new int[6];

	String getJsonData() {
		
		String strScore = sprintf_INT32(lScore, 6);
		String strIsReady = sprintf_INT32(bIsReady, 6);
		String strIsKaiPaiReady = sprintf_INT32(bIsKaiPaiReady, 6);

		String sszliumsg = String.format("table_begin|%s|%d|%d|%s|%s|%s", strParam, byRound,byMaxRound,strIsReady,strIsKaiPaiReady, strScore);
		
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);
		
		return json.toString();
	}
};

//用户出牌
class SUBCMD_S_TableSide extends IJsonExport {
	int bySeatID;
	int	bIsReady;//
	int	bIsKaiPaiReady;//
	int vecCardType[] = new int[3];
	int byPai[] = new int[13]; // 桌面扑克 //been 4
	int maPai = 0;
	int teshuPai = 0;
	String getJsonData() {

		String strCardType = sprintf_BYTE(vecCardType, 3);
		String strPai = sprintf_BYTE(byPai, 13);
		
		String sszliumsg = String.format("table_side|%d|%d|%d|%s|%s|%d|%d", bySeatID,bIsReady,bIsKaiPaiReady,strCardType, strPai,maPai,teshuPai);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

//用户出牌
class SUBCMD_S_TableEnd extends IJsonExport {
	int cbSceneStatus;

	String getJsonData() {

		String sszliumsg = String.format("table_end|%d", cbSceneStatus);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};
//TODO
class SUBCMD_S_STAGE extends IJsonExport { // 同步房间玩家信息
	String szStage;
	int needDealTime;	
	int	vecIsReady[] = new int[6];//
	int	vecIsKaiPaiReady[] = new int[6];//
	int m_vecCardType[][] = new int[6][3];
	int m_bTableCardArray[][] = new int[6][13]; // 桌面扑克 //been 4
	

	public String getJsonData(){

		String strReady = sprintf_BYTE(vecIsReady, 6);
		String strKaiPaiReady = sprintf_BYTE(vecIsKaiPaiReady, 6);
		String strCardType = "";//sprintf_BYTE(m_vecCardType, 4);		
		String strTableCard = "";//sprintf_BYTE(m_bTableCardArray, 52);		
		
		String sszliumsg = String.format("stage|%s|%d|%s|%s|%s|%s", szStage, needDealTime, strReady,strKaiPaiReady, strCardType,strTableCard);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);		

		return json.toString();
	}
};
//TODO
class SUBCMD_S_REPORT extends IJsonExport {
	int cbReason;
	int whoDismiss;
	int vecMaxWinScore[] = new int[6];
	int vecWinScore[] = new int[6];
	int vecLoseScore[] = new int[6];
	double vecResultScore[] = new double[6];
	int vecDaQiangTime[] = new int[6];
	int vecBeiDaTime[] = new int[6];
	int vecQuanLeiTime[] = new int[6];

	String getJsonData() {


		String strMaxWinScore = sprintf_INT32(vecMaxWinScore, 6);
		String strWinScore = sprintf_INT32(vecWinScore, 6);
		String strLoseScore = sprintf_INT32(vecLoseScore, 6);
		String strResultScore = sprintf_DOUBLE(vecResultScore, 6);
		String strDaQiang = sprintf_INT32(vecDaQiangTime, 6);
		String strBeiDa = sprintf_INT32(vecBeiDaTime, 6);
		String strQuanLei = sprintf_INT32(vecQuanLeiTime, 6);

		String sszliumsg = String.format("report|%d|%d|%s|%s|%s|%s|%s|%s|%s", cbReason, whoDismiss, strMaxWinScore, strWinScore,
				strLoseScore, strResultScore,strDaQiang,strBeiDa,strQuanLei);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}

	String getData() {

		String strWinScore = sprintf_INT32(vecWinScore, 6);
		String strLoseScore = sprintf_INT32(vecLoseScore, 6);
		String strResultScore = sprintf_DOUBLE(vecResultScore, 6);

		return String.format("report|%d|%d|%s|%s|%s", cbReason, whoDismiss, strWinScore, strLoseScore, strResultScore);
	}
};


/***
 * 房间信息
 */
//TODO
class SUBCMD_S_CardStatus extends IJsonExport {// 同步房间玩家信息
	int m_cbCardStatus[] = new int[6];

	String getJsonData() {
		String card_status = Arrays.toString(m_cbCardStatus);
		card_status = card_status.substring(1, card_status.length() - 1);

		String sszliumsg = String.format("card_status|%s", card_status);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};


/***
 * 房间信息
 */
class SUBCMD_S_StatusFree extends IJsonExport {// 同步房间玩家信息

	int m_lCellScore;// 房间ID

	String getJsonData() {

		String sszliumsg = String.format("status_free|%d", m_lCellScore);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

//TODO
//同步房间玩家信息
class SUBCMD_S_StatusPlay extends IJsonExport {
	int m_lCellScore;// 房间ID
	int m_cntTableChip[] = new int[6];// 1x,3x,5x,8x,10x
	int m_cbCardStatus[] = new int[6];
	int m_AllBetCoin[] = new int[6];// 底注
	int m_AllUserCoin[] = new int[6];// 每个玩家多少钱

	String getJsonData() {
		String strTableChip = Arrays.toString(m_cntTableChip);
		strTableChip = strTableChip.substring(1, strTableChip.length() - 1);

		String strCardStatus = Arrays.toString(m_cbCardStatus);
		strCardStatus = strCardStatus.substring(1, strCardStatus.length() - 1);

		String strBetCoin = Arrays.toString(m_AllBetCoin);
		strBetCoin = strBetCoin.substring(1, strBetCoin.length() - 1);

		String strUserCoin = Arrays.toString(m_AllUserCoin);
		strUserCoin = strUserCoin.substring(1, strUserCoin.length() - 1);

		String sszliumsg = String.format("status_play|%d|%s|%s|%s|%s", m_lCellScore, strTableChip, strCardStatus,
				strBetCoin, strUserCoin);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};

class SUBCMD_S_Start extends IJsonExport 
{
	int		byRound;//
	int		byMaxRound;//	
	int		vecIsReady[] = new int[6];//
	public String getJsonData(){
		String strIsReady = sprintf_BYTE(vecIsReady, 6);

		String sszliumsg = String.format("start|%d|%d|%s", byRound, byMaxRound,strIsReady);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();			
	}
};
//TODO
class SUBCMD_S_FaPai extends IJsonExport 
{
	int		byRound;//
	int		byMaxRound;//	
	int		vecIsReady[] = new int[6];//
	int		byPai[] = new int[13];			// 
	int     maPai =  0;
	int     teshuPai = 0;
	public String getJsonData(){
		String strIsReady = sprintf_BYTE(vecIsReady, 6);
		String strPai = sprintf_BYTE(byPai, 13);

		String sszliumsg = String.format("fapai|%d|%d|%s|%s|%d|%d", byRound, byMaxRound,strIsReady, strPai,maPai,teshuPai);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();			
	}
};

class SUBCMD_S_QiangZhuang extends IJsonExport {
	int lUid; // 当前玩家
	int wChairID; // 玩家座位号
	int wPower; // 下注金币

	public String getJsonData() {

		String sszliumsg = String.format("qiangzhuang|%d|%d|%d", lUid, wChairID, wPower);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};
//TODO
class SUBCMD_S_DingZhuang extends IJsonExport {
	int lUid; // 当前玩家
	int wChairID; // 玩家座位号
	int wPower; // 下注金币
	int byQiangZhuang[] = new int[6]; // 抢庄玩家的动画需要

	public String getJsonData() {

		String strQiangZhuang = sprintf_BYTE(byQiangZhuang, 6);

		String sszliumsg = String.format("dingzhuang|%d|%d|%d|%s", lUid, wChairID, wPower, strQiangZhuang);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();

	}
};

//TODO
class SUBCMD_S_KaiPaiReady extends IJsonExport 
{
	int		byRound;//	
	int		vecIsKaiPaiReady[] = new int[6];// 
	public String getJsonData(){
		String strIsKaiPaiReady = sprintf_BYTE(vecIsKaiPaiReady, 6);

		String sszliumsg = String.format("kaipai_ready|%d|%s", byRound,strIsKaiPaiReady);
		
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();			
	}
};
//TODO
class SUBCMD_S_JieSuan extends IJsonExport {
	int		byRound;//
	double 	nRoundScore[] = new double[6];
	int 	nUserScore[] = new int[6];
	
	int		vecIsReady[] = new int[6];//	
	int		byPai[][] = new int[6][13];			// 	
	double lShuiShou[] = new double[6];
	double lUserCoin[] = new double[6];
	public String getJsonData(){
		
		String strRoundScore = sprintf_DOUBLE(nRoundScore, 6);
		String strResultScore = sprintf_INT32(nUserScore, 6);
		
		String strIsReady = sprintf_BYTE(vecIsReady, 6);
		
		String strPai0 = sprintf_BYTE(byPai[0], 13);
		String strPai1 = sprintf_BYTE(byPai[1], 13);
		String strPai2 = sprintf_BYTE(byPai[2], 13);
		String strPai3 = sprintf_BYTE(byPai[3], 13);
		String strPai4 = sprintf_BYTE(byPai[4], 13);
		String strPai5 = sprintf_BYTE(byPai[5], 13);
		String userShui = sprintf_DOUBLE(lShuiShou, 6);
		String userCoin = sprintf_DOUBLE(lUserCoin, 6);
		


		String sszliumsg = String.format("jiesuan|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", byRound, strRoundScore, strResultScore,strIsReady, strPai0, strPai1, strPai2, strPai3,strPai4,strPai5,userShui,userCoin);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};
//TODO
class SUBCMD_S_SuanFen extends IJsonExport {
	int		byRound;//
	int		nScore[][][] = new int[6][6][3];
	public String getJsonData(){
		
		String strScore00 = sprintf_BYTE(nScore[0][0], 3);
		String strScore01 = sprintf_BYTE(nScore[0][1], 3);
		String strScore02 = sprintf_BYTE(nScore[0][2], 3);
		String strScore03 = sprintf_BYTE(nScore[0][3], 3);
		String strScore04 = sprintf_BYTE(nScore[0][4], 3);
		String strScore05 = sprintf_BYTE(nScore[0][5], 3);
		
		String strScore10 = sprintf_BYTE(nScore[1][0], 3);
		String strScore11 = sprintf_BYTE(nScore[1][1], 3);
		String strScore12 = sprintf_BYTE(nScore[1][2], 3);
		String strScore13 = sprintf_BYTE(nScore[1][3], 3);
		String strScore14 = sprintf_BYTE(nScore[1][4], 3);
		String strScore15 = sprintf_BYTE(nScore[1][5], 3);
		
		String strScore20 = sprintf_BYTE(nScore[2][0], 3);
		String strScore21 = sprintf_BYTE(nScore[2][1], 3);
		String strScore22 = sprintf_BYTE(nScore[2][2], 3);
		String strScore23 = sprintf_BYTE(nScore[2][3], 3);
		String strScore24 = sprintf_BYTE(nScore[2][4], 3);
		String strScore25 = sprintf_BYTE(nScore[2][5], 3);
		
		String strScore30 = sprintf_BYTE(nScore[3][0], 3);
		String strScore31 = sprintf_BYTE(nScore[3][1], 3);
		String strScore32 = sprintf_BYTE(nScore[3][2], 3);
		String strScore33 = sprintf_BYTE(nScore[3][3], 3);
		String strScore34 = sprintf_BYTE(nScore[3][4], 3);
		String strScore35 = sprintf_BYTE(nScore[3][5], 3);
		
		String strScore40 = sprintf_BYTE(nScore[4][0], 3);
		String strScore41 = sprintf_BYTE(nScore[4][1], 3);
		String strScore42 = sprintf_BYTE(nScore[4][2], 3);
		String strScore43 = sprintf_BYTE(nScore[4][3], 3);
		String strScore44 = sprintf_BYTE(nScore[4][4], 3);
		String strScore45 = sprintf_BYTE(nScore[4][5], 3);
		
		String strScore50 = sprintf_BYTE(nScore[5][0], 3);
		String strScore51 = sprintf_BYTE(nScore[5][1], 3);
		String strScore52 = sprintf_BYTE(nScore[5][2], 3);
		String strScore53 = sprintf_BYTE(nScore[5][3], 3);
		String strScore54 = sprintf_BYTE(nScore[5][4], 3);
		String strScore55 = sprintf_BYTE(nScore[5][5], 3);
		


		String sszliumsg = String.format("suanfen|%d|%s#%s#%s#%s#%s#%s|%s#%s#%s#%s#%s#%s|%s#%s#%s#%s#%s#%s|%s#%s#%s#%s#%s#%s|%s#%s#%s#%s#%s#%s|%s#%s#%s#%s#%s#%s",byRound,
				strScore00,strScore01,strScore02,strScore03,strScore04,strScore05,
				strScore10,strScore11,strScore12,strScore13,strScore14,strScore15,
				strScore20,strScore21,strScore22,strScore23,strScore24,strScore25,
				strScore30,strScore31,strScore32,strScore33,strScore34,strScore35,
				strScore40,strScore41,strScore42,strScore43,strScore44,strScore45,
				strScore50,strScore51,strScore52,strScore53,strScore54,strScore55);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();
	}
};
//TODO
class SUBCMD_S_Teshupai extends IJsonExport 
{
	int		uid;//	
	int		vecTeshupai[] = new int[6];// 
	public String getJsonData(){
		
		String teshupaiStr = sprintf_BYTE(vecTeshupai, 6);
		String sszliumsg = String.format("kaipai_teshupai|%d|%s", uid,teshupaiStr);
		
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);

		return json.toString();			
	}
};


//文字聊天
class SUBCMD_S_Text extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	String szContent;

	String getJsonData() {
		String sszliumsg = String.format("text|%d|%d|%s", m_lUid, m_wUserChairID, szContent);

		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", sszliumsg);
		return json.toString();
	}
};


class SUBCMD_S_VoiceMsg extends IJsonExport{
	int m_lUid;
	int m_wUserChairID;
	int m_maxClip;
	int m_currClip;
	float seconds;
	String data;
	
	String getJsonData() {

		String mjmsg = String.format("voicemsg|%d|%d|%f|%s|%d|%d", m_lUid, m_wUserChairID, seconds, data,m_maxClip,m_currClip);
		JSONObject json = new JSONObject();
		json.put("command", "sszliumsg");
		json.put("sszliumsg", mjmsg);

		return json.toString();
	}
};


